<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'home';
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$this->model('member')->upmember();
$return['pluginset']['ailogo']=tomedia($return['pluginset']['ailogo']);
$return['basic']=$return['pluginset'];
if($_RQ['op']=='home'){
	if($_RQ['id']){
		$return['item']=pdo_get('jy_aiagent_shengwenlog',array('id'=>$_RQ['id'],'uniacid'=>$_SESSION['uniacid']));
		$_RQ['agentid']=$return['item']['agentid'];
	}else{
		$return['item']=array('agentid'=>$_RQ['agentid']);
	}
	$agent=pdo_get('jy_aiagent_useragent',array('id'=>$_RQ['agentid'],'uniacid'=>$_SESSION['uniacid']));
	$this->model('agent')->getembedding($agent);
	$return['params']=array('agentid'=>$_RQ['agentid'],'voicesex'=>0,'yuyuantype'=>0);
	$return['sharedata']=array(
		'title'=>$return['goods']['title'],
		'desc'=>$return['basic']['share_desc'],
		'link'=>custom_url('jy_aiagent/index//fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>$return['post']['logo'],
	);
	set_html('title','编辑声纹');
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(!$postdata['title']){
		exi('请输入标题','error');
	}
	if(!$postdata['logid'] && !$postdata['id']){
		exi('请选择语音！','error');
	}
	$result=model('core/wxapp_api')->msgSecCheck($postdata['title']);
	if($result['errcode']){
		exi('标题内容可能不合法！','error');
	}
	if($postdata['logid']){
		$logitem=pdo_get('jy_aiagent_useragentlogitem',array('id'=>$postdata['logid'],'uniacid'=>$_SESSION['uniacid']));
		$postdata['embedding']=$logitem['embedding'];
	}else{
		$postdata['embedding']=pdo_getcolumn('jy_aiagent_shengwenlog',array('id'=>$postdata['id'],'uniacid'=>$_SESSION['uniacid']),'embedding');
	}
	$this->model('agent')->addshengwen($postdata);
	exi('操作成功！','','/shengwen/');
}